/**
 * Created by 刘晓鑫 on 2016/8/1 如果页面高度不够，底部版权信息在页面最底部
 */
$(document).ready(function(){
    var Winh = $(window).height();
    var Bodyh = $("body").height();
    if(Winh>Bodyh){
        var martop = Winh-Bodyh+50;
        $(".footer").css({"margin-top":martop});
    }
    else{
        return;
    }
})


/**
 *Created by 刘晓鑫 on 2016/8/2 解决ie7下 对象不支持“getElementsByClassName”属性或方法
 * */
if(!document.getElementsByClassName){
    document.getElementsByClassName = function(className, element){
        var children = (element || document).getElementsByTagName('*');
        var elements = new Array();
        for (var i=0; i<children.length; i++){
            var child = children[i];
            var classNames = child.className.split(' ');
            for (var j=0; j<classNames.length; j++){
                if (classNames[j] == className){
                    elements.push(child);
                    break;
                }
            }
        }
        return elements;
    };
}
/**
*Created by 刘晓鑫 on 2016/8/1.弹窗方法*/
// 根据当前页面于滚动条的位置，设置提示对话框的TOP和left
    function showMessagemox(obj) {
        var objw = $(window);//当前窗口
        var a = document.getElementsByClassName(obj);
        var objc = $(a);//当前对话框
        var brsw = objw.width();
        var brsh = objw.height();
        var sclL = $(window).scrollLeft();
        var sclT = $(window).scrollTop();
        var curw = objc.width();
        var curh = objc.height();
        //计算对话框居中时的左边距
        var left = sclL + (brsw - curw) / 2;
        var top = sclT + (brsh - curh) / 2;

        //设置对话框居中
        objc.css({
            "left": left,
            "top": top,
            "display": "block"
        });
    }
    //显示透明背景
    function showConceal() {
        $(".conceal").eq(0).css("opacity", "0.3").show();
    }
    //隐藏弹出框
    function hideModal() {
        $(".messagemox").css("display", "none");
        $(".conceal").hide();
    }
    //弹出框关闭按钮单击事件
    $(".close").click(function () {
        $(".conceal").hide();
        hideModal();
    });
    //添加确定按钮事件
    $(".ok").click(function () {
        hideModal();
    });
    //添加取消按钮事件
    $(".noOk").click(function () {
        hideModal();
    });
    //单击空白处关闭
    $(".conceal").click(function () {
        hideModal();
    })
    //注册页面“使用协议”按钮的触发事件
    $(".use-protocol").click(function () {
        hideModal();
        showConceal();
        showMessagemox("use-protocol-wrap");
    });
/**
 *Created by 刘晓鑫 on 2016/8/4.遍历导航并变色*/
$(".header .nav>li").each(function(){
    var navlititle = $(this).children("a").text()
    if(navlititle==$(".pagetitle").text()){
        $(this).addClass("on").siblings().removeClass("on");
    }
})